/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hvkdbmc.entities;

import java.util.ArrayList;

/**
 *
 * @author admin
 */
public class HVKColumnInfo {

    public Long id;
    public String name;
    public String type;
    public Long typeSize;
    public Object value;
    public boolean isPrimaryKey;
    public String seq;
    public Object defaultValue;
    public boolean isNullAble;
    public String description;
    public boolean isIdentity;
    public ArrayList<String> tableRefFrom;
    public ArrayList<String> columnRefFrom;
    public ArrayList<String> tableRefTo;
    public ArrayList<String> columnRefTo;

    public HVKColumnInfo(String name, boolean isPrimaryKey, String seq) {
        this.name = name;
        this.isPrimaryKey = isPrimaryKey;
        this.seq = seq;
    }

    public HVKColumnInfo(String name, String type, boolean isPrimaryKey, String seq) {
        this.name = name;
        this.type = type;
        this.isPrimaryKey = isPrimaryKey;
        this.seq = seq;
    }
    
    

    public HVKColumnInfo() {
        this.id = -1L;
        this.name = null;
        this.type = null;
        this.typeSize = 0L;
        this.value = null;
        this.isPrimaryKey = false;
        this.seq = null;
        this.defaultValue = null;
        this.isNullAble = true;
        this.description = null;
        this.isIdentity = false;
        this.tableRefFrom = new ArrayList<String>();
        this.columnRefFrom = new ArrayList<String>();
        this.tableRefTo = new ArrayList<String>();
        this.columnRefTo = new ArrayList<String>();
    }

    public HVKColumnInfo(Long id, String name, String type,Long typeSize, Object value,boolean isPrimaryKey, String seq, Object defaultValue, boolean isNullAble, String description, boolean isIdentity, ArrayList<String> tableRefFrom, ArrayList<String> columnRefFrom, ArrayList<String> tableRefTo, ArrayList<String> columnRefTo) {
        this.id = id;
        this.name = name;
        this.type = type;
        this.typeSize = typeSize;
        this.value = value;
        this.isPrimaryKey = isPrimaryKey;
        this.seq = seq;
        this.defaultValue = defaultValue;
        this.isNullAble = isNullAble;
        this.description = description;
        this.isIdentity = isIdentity;
        this.tableRefFrom = tableRefFrom;
        this.columnRefFrom = columnRefFrom;
        this.tableRefTo = tableRefTo;
        this.columnRefTo = columnRefTo;
    }
    
    public String getFieldName()
    {
        String[] nameParts = name.split("_");
        String result = "";
        for (String p : nameParts) {
            String pP = p.replace("_", "");
            pP = pP.toLowerCase();
            if (pP.length() >= 1) {
                pP = pP.substring(0, 1).toUpperCase() + pP.substring(1);
            }
            result += pP;
        }
         if (result.length() >= 1) {
                result = result.substring(0, 1).toLowerCase() + result.substring(1);
            }
       return result;
    }
}
